package cn.itrip.auth.service;

import com.cloopen.rest.sdk.CCPRestSmsSDK;
import org.springframework.stereotype.Service;

import java.util.HashMap;
@Service("smsService")
public class SmsServiceImpl implements SmsService {

    public void send(String to,String templateId,String[] datas) throws Exception{
        CCPRestSmsSDK sdk = new CCPRestSmsSDK();
        sdk.init("app.cloopen.com","8883");
        sdk.setAccount("8a216da8681259360168354738fb1242","a3ddd284c7154c3789ce34b09c8d3b65");
        sdk.setAppId("8a216da86812593601683547394d1248");

        HashMap result = sdk.sendTemplateSMS(to,templateId,datas);

        if ("000000".equals(result.get("statusCode")))
            System.out.println("短信发送成功");
        else
            throw new Exception(result.get("statusCode")+toString()+":"+result.get("statusMsg").toString());

    }
}